package com.example.mingyue.datasource;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mingyue.common.PageBean;
import com.example.mingyue.model.entity.Picture;
import com.example.mingyue.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 查询图片资源的统一规范
 */
@Service
public class PictureDataSource implements DataSource<Picture>{

    @Autowired
    private PictureService pictureService;

    @Override
    public PageBean<Picture> doSearch(String searchText, Integer page, Integer pageSize) {

        IPage<Picture> picture = pictureService.searchPicture(searchText,page,pageSize);
        List<Picture> pictureList = picture.getRecords();

        PageBean pageBean = new PageBean(99,pictureList);
        //获取图片资源
        return pageBean;
    }
}
